home *** CD-ROM | disk | FTP | other *** search
/ All for Cell Phones: Sony Ericsson / Sony-Ericsson 2004.iso / Java / BounceText / BounceText.jar / com / anyEase / ScreenSaver / Block.class (.txt) next >
Encoding:
Java Class File  |  2002-09-05  |  1.8 KB  |  102 lines

  1. package com.anyEase.ScreenSaver;
  2.  
  3. import javax.microedition.lcdui.Font;
  4. import javax.microedition.lcdui.Graphics;
  5.  
  6. public class Block {
  7.    // $FF: renamed from: nX int
  8.    int field_0;
  9.    // $FF: renamed from: nY int
  10.    int field_1;
  11.    int nX2;
  12.    int nY2;
  13.    int nWidth;
  14.    int nHeight;
  15.    int ScrWidth;
  16.    int ScrHeight;
  17.    byte nSpeed = 1;
  18.    byte xDir = 1;
  19.    byte yDir = 1;
  20.    String strLabel;
  21.    byte nType;
  22.  
  23.    public Block(String var1, int var2, int var3) {
  24.       this.strLabel = var1;
  25.       this.ScrWidth = var2;
  26.       this.ScrHeight = var3;
  27.       this.nType = 1;
  28.       this.setSize();
  29.    }
  30.  
  31.    public int getHeight() {
  32.       return this.nHeight;
  33.    }
  34.  
  35.    public String getLabel() {
  36.       return this.strLabel;
  37.    }
  38.  
  39.    public byte getType() {
  40.       return this.nType;
  41.    }
  42.  
  43.    public int getWidth() {
  44.       return this.nWidth;
  45.    }
  46.  
  47.    public int getX() {
  48.       return this.field_0;
  49.    }
  50.  
  51.    public int getY() {
  52.       return this.field_1;
  53.    }
  54.  
  55.    public void init(int var1, int var2, int var3, int var4) {
  56.       this.field_0 = var1;
  57.       this.field_1 = var2;
  58.       this.xDir = (byte)(var3 >= 0 ? 1 : -1);
  59.       this.yDir = (byte)(var4 >= 0 ? 1 : -1);
  60.    }
  61.  
  62.    public void move() {
  63.       this.nX2 = this.field_0;
  64.       this.nY2 = this.field_1;
  65.       int var1 = this.field_0 + this.xDir * this.nSpeed;
  66.       if (var1 + this.nWidth <= this.ScrWidth && var1 >= 0) {
  67.          this.field_0 = var1;
  68.       } else {
  69.          this.xDir *= -1;
  70.       }
  71.  
  72.       var1 = this.field_1 + this.yDir * this.nSpeed;
  73.       if (var1 + this.nHeight <= this.ScrHeight && var1 >= 0) {
  74.          this.field_1 = var1;
  75.       } else {
  76.          this.yDir *= -1;
  77.       }
  78.  
  79.    }
  80.  
  81.    public void paint(Graphics var1) {
  82.       var1.setColor(0);
  83.       var1.fillRect(this.nX2, this.nY2, this.nWidth, this.nHeight);
  84.       var1.setColor(255, 255, 255);
  85.       var1.drawString(this.strLabel, this.field_0, this.field_1, 20);
  86.    }
  87.  
  88.    public void setLabel(String var1) {
  89.       this.strLabel = var1;
  90.       this.setSize();
  91.    }
  92.  
  93.    public void setSize() {
  94.       this.nWidth = Font.getDefaultFont().stringWidth(this.strLabel);
  95.       this.nHeight = Font.getDefaultFont().getHeight();
  96.    }
  97.  
  98.    public void setType(byte var1) {
  99.       this.nType = var1;
  100.    }
  101. }
  102.